/**
 * 
 */
package com.dsp.services.impl;

import java.io.Serializable; 
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.core.util.DspUtil;
import com.core.util.GenericDAO;
import com.core.util.GenericServiceHibernate;
import com.dsp.bean.User;
import com.dsp.dao.UserDAO;
import com.dsp.services.UserService;

/**
 * @author laker
 * 
 */
@Service("userService")
@Transactional
public class UserServiceImpl extends GenericServiceHibernate<User, Long> implements UserService {


	private UserDAO userDAO;
	
	@Resource(name="userDAO")
	public void setDAO(GenericDAO<User, Serializable> dao){
		super.setDao(dao);
	}
	
	@Override
	public User findByUserName(String condition) {
		User query = new User();
		query.setUsername(condition);
		List<User> l = super.getDao().getCondition(query);
		if (DspUtil.isEmptyList(l)) {
			return null;
		}
		return l.get(0);
	}

	/**
	 * @return the userDAO
	 */
	public UserDAO getUserDAO() {
		return userDAO;
	}

	/**
	 * @param userDAO the userDAO to set
	 */
	public void setUserDAO(UserDAO userDAO) {
		this.userDAO = userDAO;
	}
	
	
}
